package com.example.demo.Controller;

import com.example.demo.WebSocket.Game_Hall_Socket;
import com.example.demo.WebSocket.Game_Room_Socket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;

@Service
@EnableWebSocket
public class Web_Socket_Controller implements WebSocketConfigurer {
    @Autowired
    private Game_Hall_Socket gameHallSocket;
    @Autowired
    private Game_Room_Socket gameRoomSocket;
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(gameHallSocket,"/findMatch").addInterceptors(new HttpSessionHandshakeInterceptor());
        registry.addHandler(gameRoomSocket,"/game").addInterceptors(new HttpSessionHandshakeInterceptor());
    }
}
